#!/bin/bash
clear

TEXT='\033[30;107;2m'
INFO='\033[97;44m'
WARNING='\033[97;43m'
ERROR='\033[97;41m'
SUCCESS='\033[97;42m'
GREEN='\033[92m'
YELLOW='\033[93m'
RESET='\033[0m'

if [ "${EUID}" -ne 0 ]; then
    echo -e "${ERROR} RALAT ${RESET}${TEXT} You need to run this script as root! ${RESET}"; exit 1
fi

senarai_pengguna=$(grep -c -E "^# " "/usr/local/etc/v2ray/.trojan")
if [[ $senarai_pengguna == 0 ]];then
	echo "Anda tidak mempunyai pelanggan sedia ada"; exit 1
fi

# getClient=$(grep -E "^# " "/usr/local/etc/v2ray/.trojan" | cut -d ' ' -f 2-3 | sed -n "${_nouser}"p)
nama_pengguna=$(grep -E "^# " "/usr/local/etc/v2ray/.trojan" | cut -d ' ' -f 2 | sed -n "${_nouser}"p)
tarikh_luput=$(grep -E "^# " "/usr/local/etc/v2ray/.trojan" | cut -d ' ' -f 3 | sed -n "${_nouser}"p)
sed -i "/^# $nama_pengguna $tarikh_luput/d" /usr/local/etc/v2ray/.trojan
sed -i '/^,"'"$nama_pengguna"'"$/d' /etc/trojan/trojan_tcp-tls.json

clear
echo
echo -e "${TEXT} ========================================================== ${RESET}"
echo -e "${TEXT} TROJAN - PADAM AKAUN                                       ${RESET}"
echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
echo
echo -e "${SUCCESS} INFO ${RESET}${TEXT} Berjaya memadamkan akaun pengguna ${RESET}"
echo
echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
echo -e "${TEXT} Created by Doctype, Powered by Cybertize.                  ${RESET}"
echo -e "${TEXT} Copyright 2021, Allright Reserved.                         ${RESET}"
echo -e "${TEXT} ========================================================== ${RESET}"
echo
